
const canvas111 = document.getElementById('game');
const context = canvas.getContext('2d');
context.font = "40px Arial";

let textNeedMove = false;
let textPositionX = 0;

window.addEventListener('click', function (){
    console.log('click')
    textNeedMove = !textNeedMove;
})


function enterFrame() {
    if(textNeedMove) {
        textPositionX++;
    }
    console.log('enter-frame');
    context.clearRect(0, 0, canvas.width, canvas.height)
    context.fillText('helloworld', 1 + textPositionX, 40);
    //回调函数
    //每进入新一帧开始的时候执行
    requestAnimationFrame(enterFrame)
}

function aaa(){
    //类型推断
    return 1;
}

enterFrame()